<?php

function retrieve_perjanjian_data(&$data, $kode, $id_po = "") {
    $CI = &get_instance();
    $kode = $CI->security->xss_clean($kode);
    $result = $CI->model_transaksi_penyewaan->getPerjanjianData("WHERE i.id_perjanjian = '". mysql_escape_string($kode)."'");    
    $row = $result->row();
    
    $data["keagenan_kapal"] = $row->keagenan_kapal;
    $data["id_perjanjian"] = $row->id_perjanjian;
    $data["nomor_perjanjian"] = $row->nomor_perjanjian;    
    $data["tanggal_perjanjian"] = $row->tanggal_perjanjian;
    $data["id_vessel"] = $row->id_vessel;
    $data["nama_vessel"] = $row->nama_vessel;
    $data["keterangan_vessel"] = $row->keterangan_vessel;
    $data["using_dollar_currency"] = $row->using_dollar_currency;
    $data["approved_by"] = $row->approved_by;
    $data["tambahkan_ppn"] = $row->tambahkan_ppn;
    $data["penerbit_perjanjian"] = $row->penerbit_perjanjian;    
    $data["diskon"] = $row->diskon;
    $data["kesediaan_muat"] = $row->kesediaan_muat;
    $data["jenis_muatan"] = $row->jenis_muatan;
    $data["kondisi_kontrak"] = $row->kondisi_kontrak;
    $data["pelabuhan_muat"] = $row->pelabuhan_muat;
    $data["pelabuhan_bongkar"] = $row->pelabuhan_bongkar;
    $data["jumlah_hari"] = $row->jumlah_hari;
    $data["jumlah_muatan"] = $row->jumlah_muatan;
    $data["pengirim_barang"] = $row->pengirim_barang;
    $data["penerima_barang"] = $row->penerima_barang;
    $data["asuransi_barang"] = $row->asuransi_barang;
    $data["asuransi_kapal"] = $row->asuransi_kapal;
    $data["uang_tambang"] = $row->uang_tambang;        
    $data["kondisi_uang_tambang"] = $row->kondisi_uang_tambang;
    $data["cara_pembayaran"] = $row->cara_pembayaran;
    $data["denda_keterlambatan"] = $row->denda_keterlambatan;
    $data["remarks"] = $row->remarks;
    $data["id_bank"] = $row->id_bank;
    $data["id_customer"] = $row->id_customer;
    $data["nama_customer"] = $row->nama_customer;    
    $data["telepon_customer"] = $row->telepon_customer;    
    $data["alamat_customer"] = $row->alamat_customer;    
    $data["fax_customer"] = $row->fax_customer;    
    $data["subject"] = $row->subject;
    $data["submitter"] = $row->submitter;
    $data["date_submit"] = $row->date_submit;
    $data["ppn"] = $row->ppn;
    $data["cabang"] = $row->cabang;
    $data["nomor_rekening"] = $row->nomor_rekening;
    $data["nama_bank"] = $row->nama_bank;
    $data["id_customer"] = $row->id_customer;
    $data["alamat_detail_customer"] = $row->alamat_detail_customer;    
    $data["alamat_komplit"] = $row->alamat_customer."\n".$row->kota_customer."\n".$row->kode_pos_customer;
    $data["kontak_komplit"] = $row->telepon_customer."/".$row->fax_customer."/".$row->email_customer;
    $data["attendance"] = $row->attendance;    
    $data["use_header"] = $CI->model_transaksi_penyewaan->get_scalar("SELECT tampilkan_header FROM master_setting_laporan WHERE nama_laporan = 'SURAT_PERJANJIAN1'", "tampilkan_header");    
}

function retrieve_invoice_data(&$data, $kode, $id_po = "") {    
    $CI = &get_instance();
    $kode = $CI->security->xss_clean($kode);    
    $result = $CI->model_transaksi_penyewaan_invoice->getInvoiceData("WHERE i.id_invoice = '". mysql_escape_string($kode)."'");        
    $row = $result->row();
    
    $data["id_invoice"] = $row->id_invoice;
    $data["tanggal_invoice"] = $row->tanggal_invoice;
    $data["nomor_invoice"] = $row->nomor_invoice;
    $data["id_perjanjian"] = $row->id_po;
    $data["crc"] = $row->using_dollar_currency;    
    $data["penerbit_invoice"] = $row->penerbit_invoice;
    $data["diskon_iv"] = $row->diskon ? $row->diskon : 0;
    $data["item_iv"] = $CI->model_transaksi_penyewaan_invoice->getInvoiceItem($data["id_invoice"]);
    $data["bank"] = $CI->model_transaksi_penyewaan_invoice->getInvoiceBank($data["crc"]);        
    
    if ($id_po == ""){
        $id_po = $row->id_perjanjian;
    }
    retrieve_perjanjian_data($data, $id_po);    
    $data["using_dollar_currency"] = $row->using_dollar_currency;  
    $data["tambahkan_ppn"] = $row->tambahkan_ppn;    
    $data["item"] = $data["item_iv"];
    $data["use_header"] = $CI->model_transaksi_penyewaan_invoice->get_scalar("SELECT tampilkan_header FROM master_setting_laporan WHERE nama_laporan = 'INVOICE_KE_PELANGGAN'", "tampilkan_header");      
}
?>
